package com.yc;


import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
public class Test3_client {
    public static void main(String[] args) throws IOException {
        //192.168.16.222
        Socket s =new Socket("localhost",10001);
        System.out.println("联接成功,"+s);

        //用输入流来连接时间
        try(InputStream iis =s.getInputStream();) {
            byte[] bs= new byte[1024];
            int length= -1;
            System.out.println("客户等待服务端地响应");
            while( (length=iis.read(bs,0,bs.length))!=-1){
                String str =new String(bs,0,length);
                System.out.println("服务端的响应,输出："+str);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println("客户端断开服务端的联接");
        s.close();
    }
}
